package com.eastedu.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;

/**
 * 章节树节点
 *
 * @author luozhenzhong
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@MappedSuperclass
public class CommonTreeEntity extends BaseTreeWithRootEntity {

    /**
     * 全局唯一标识符
     */
    @Column(name = "guid", nullable = false, columnDefinition = "varchar(36) COMMENT '全局唯一标识符'")
    private String guid;

    /**
     * 知识节点名称
     */
    @Column(name = "name", nullable = false, columnDefinition = "varchar(200) COMMENT '知识节点名称'")
    private String name;

    /**
     * 树层级
     */
    @Column(name = "level", nullable = false, columnDefinition = "int COMMENT '树层级'")
    private Integer level;

    /**
     * 备注
     */
    @Column(name = "remark", columnDefinition = "varchar(500) COMMENT '备注'")
    private String remark;

    /**
     * 顺序
     */
    @Column(name = "`order`", nullable = false, columnDefinition = "int COMMENT '顺序'")
    @TableField("`order`")
    private Integer order;

    /**
     * 创建用户ID
     */
    @Column(name = "create_user_id", nullable = false, columnDefinition = "bigint(20) COMMENT '创建用户ID'")
    private Long createUserId;


    /**
     * 序列号
     */
    @Column(name = "serial_number", columnDefinition = "varchar(200) COMMENT '序列号'")
    private String serialNumber;

    /**
     * 是否可用
     */
    @TableLogic(value = "1", delval = "0")
    @TableField(value = "available", fill = FieldFill.INSERT)
    @Column(name = "available", nullable = false, columnDefinition = "bit default 1 COMMENT '是否可用'")
    private Boolean available;

    @Version
    @Column(name = "`version`", nullable = false, columnDefinition = "int default 0 COMMENT '版本号'")
    private Integer version;


    @Column(name = "freeze", nullable = false, columnDefinition = "bit(1) DEFAULT b'0' COMMENT '是否冻结'")
    private Boolean freeze;


}
